package com.elvt.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elvt.server.mapper.MenuMapper;
import com.elvt.server.mapper.MenuRoleMapper;
import com.elvt.server.pojo.MenuRole;
import com.elvt.server.service.IMenuRoleService;
import com.elvt.server.utils.RespSult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者：elvt
 * @since 2022-05-21
 */
@Service
public class MenuRoleServiceImpl extends ServiceImpl<MenuRoleMapper, MenuRole> implements IMenuRoleService {
    @Autowired
    private MenuRoleMapper menuRoleMapper;
    @Override
    @Transactional
    public RespSult updateMenuRole(Integer rid, Integer[] ids) {

                menuRoleMapper.delete(new QueryWrapper<MenuRole>().eq("rid",rid));
              if (null==ids || ids.length==0){
                  return RespSult.success("更新成功！");
              }
        Integer row = menuRoleMapper.insertRecord(rid, ids);
              if (row>0){
                  return RespSult.success("更新成功了！");
              }
        return RespSult.error("失败了");
    }
}
